<template>
  <div class="pronunciation-section">
    <el-button 
      size="small" 
      type="primary" 
      @click="playPronunciation"
      :disabled="!isPronunciationAvailable(word)"
      :loading="isPlaying"
    >
      <el-icon><Volume /></el-icon>
      播放发音
    </el-button>
    
    <el-button 
      size="small" 
      @click="stopPronunciation"
      :disabled="!isPlaying"
    >
      <el-icon><VideoPause /></el-icon>
      停止播放
    </el-button>
  </div>
</template>

<script>
import pronunciationUtils from '../utils/pronunciationUtils';

export default {
  name: 'WordPronunciation',
  props: {
    word: {
      type: Object,
      required: true
    },
    isPlaying: {
      type: Boolean,
      default: false
    }
  },
  emits: ['play', 'stop'],
  methods: {
    isPronunciationAvailable(word) {
      return pronunciationUtils.isPronunciationAvailable(word);
    },

    playPronunciation() {
      this.$emit('play');
    },

    stopPronunciation() {
      this.$emit('stop');
    }
  }
};
</script>

<style scoped>
.pronunciation-section {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
</style>
